"""
本代码由[Tkinter布局助手]生成
官网:https://www.pytk.net
QQ交流群:905019785
在线反馈:https://support.qq.com/product/618914
"""
import random
from tkinter import *
from tkinter.ttk import *
class WinGUI(Tk):
    def __init__(self):
        super().__init__()
        self.__win()
        self.tk_label_frame_md7605nf = self.__tk_label_frame_md7605nf(self)
        self.tk_label_name_xx1 = self.__tk_label_name_xx1( self.tk_label_frame_md7605nf) 
        self.tk_input_name_1 = self.__tk_input_name_1( self.tk_label_frame_md7605nf) 
        self.tk_label_data_xx1 = self.__tk_label_data_xx1( self.tk_label_frame_md7605nf) 
        self.tk_input_data_1 = self.__tk_input_data_1( self.tk_label_frame_md7605nf) 
        self.tk_button_md761j02 = self.__tk_button_md761j02( self.tk_label_frame_md7605nf) 
        self.tk_label_frame_md761rc6 = self.__tk_label_frame_md761rc6(self)
        self.tk_label_name_xx2 = self.__tk_label_name_xx2( self.tk_label_frame_md761rc6) 
        self.tk_label_data_xx2 = self.__tk_label_data_xx2( self.tk_label_frame_md761rc6) 
        self.tk_input_name_2 = self.__tk_input_name_2( self.tk_label_frame_md761rc6) 
        self.tk_input_data_2 = self.__tk_input_data_2( self.tk_label_frame_md761rc6) 
        self.tk_button_md762af1 = self.__tk_button_md762af1( self.tk_label_frame_md761rc6) 
        self.tk_button_md76csod = self.__tk_button_md76csod(self)
        self.tk_button_md76cuu3 = self.__tk_button_md76cuu3(self)
        self.tk_label_md77yav5 = self.__tk_label_md77yav5(self)
        self.tk_input_output = self.__tk_input_output(self)
        self.tk_button_md77ygzz = self.__tk_button_md77ygzz(self)
    def __win(self):
        self.title("CPU指令数拆解工具")
        # 设置窗口大小、居中
        width = 580
        height = 350
        screenwidth = self.winfo_screenwidth()
        screenheight = self.winfo_screenheight()
        geometry = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        self.geometry(geometry)
        
        self.resizable(width=False, height=False)
        
    def scrollbar_autohide(self,vbar, hbar, widget):
        """自动隐藏滚动条"""
        def show():
            if vbar: vbar.lift(widget)
            if hbar: hbar.lift(widget)
        def hide():
            if vbar: vbar.lower(widget)
            if hbar: hbar.lower(widget)
        hide()
        widget.bind("<Enter>", lambda e: show())
        if vbar: vbar.bind("<Enter>", lambda e: show())
        if vbar: vbar.bind("<Leave>", lambda e: hide())
        if hbar: hbar.bind("<Enter>", lambda e: show())
        if hbar: hbar.bind("<Leave>", lambda e: hide())
        widget.bind("<Leave>", lambda e: hide())
    
    def v_scrollbar(self,vbar, widget, x, y, w, h, pw, ph):
        widget.configure(yscrollcommand=vbar.set)
        vbar.config(command=widget.yview)
        vbar.place(relx=(w + x) / pw, rely=y / ph, relheight=h / ph, anchor='ne')
    def h_scrollbar(self,hbar, widget, x, y, w, h, pw, ph):
        widget.configure(xscrollcommand=hbar.set)
        hbar.config(command=widget.xview)
        hbar.place(relx=x / pw, rely=(y + h) / ph, relwidth=w / pw, anchor='sw')
    def create_bar(self,master, widget,is_vbar,is_hbar, x, y, w, h, pw, ph):
        vbar, hbar = None, None
        if is_vbar:
            vbar = Scrollbar(master)
            self.v_scrollbar(vbar, widget, x, y, w, h, pw, ph)
        if is_hbar:
            hbar = Scrollbar(master, orient="horizontal")
            self.h_scrollbar(hbar, widget, x, y, w, h, pw, ph)
        self.scrollbar_autohide(vbar, hbar, widget)
    def __tk_label_frame_md7605nf(self,parent):
        frame = LabelFrame(parent,text="数据1",)
        frame.place(x=10, y=10, width=555, height=115)
        return frame
    def __tk_label_name_xx1(self,parent):
        label = Label(parent,text="名称",anchor="center", )
        label.place(x=15, y=10, width=50, height=30)
        return label
    def __tk_input_name_1(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=75, y=10, width=465, height=30)
        return ipt
    def __tk_label_data_xx1(self,parent):
        label = Label(parent,text="数据",anchor="center", )
        label.place(x=15, y=50, width=50, height=30)
        return label
    def __tk_input_data_1(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=75, y=50, width=400, height=30)
        return ipt
    def __tk_button_md761j02(self,parent):
        btn = Button(parent, text="选择", takefocus=False,)
        btn.place(x=490, y=50, width=50, height=30)
        return btn
    def __tk_label_frame_md761rc6(self,parent):
        frame = LabelFrame(parent,text="数据2",)
        frame.place(x=10, y=130, width=555, height=115)
        return frame
    def __tk_label_name_xx2(self,parent):
        label = Label(parent,text="名称",anchor="center", )
        label.place(x=15, y=10, width=50, height=30)
        return label
    def __tk_label_data_xx2(self,parent):
        label = Label(parent,text="数据",anchor="center", )
        label.place(x=15, y=50, width=50, height=30)
        return label
    def __tk_input_name_2(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=75, y=10, width=465, height=30)
        return ipt
    def __tk_input_data_2(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=75, y=50, width=400, height=30)
        return ipt
    def __tk_button_md762af1(self,parent):
        btn = Button(parent, text="选择", takefocus=False,)
        btn.place(x=490, y=50, width=50, height=30)
        return btn
    def __tk_button_md76csod(self,parent):
        btn = Button(parent, text="整机", takefocus=False,)
        btn.place(x=120, y=305, width=50, height=30)
        return btn
    def __tk_button_md76cuu3(self,parent):
        btn = Button(parent, text="内核", takefocus=False,)
        btn.place(x=400, y=305, width=50, height=30)
        return btn
    def __tk_label_md77yav5(self,parent):
        label = Label(parent,text="输出",anchor="center", )
        label.place(x=25, y=260, width=50, height=30)
        return label
    def __tk_input_output(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=85, y=260, width=400, height=30)
        return ipt
    def __tk_button_md77ygzz(self,parent):
        btn = Button(parent, text="选择", takefocus=False,)
        btn.place(x=500, y=260, width=50, height=30)
        return btn
class Win(WinGUI):
    def __init__(self, controller):
        self.ctl = controller
        super().__init__()
        self.__event_bind()
        self.__style_config()
        self.ctl.init(self)
    def __event_bind(self):
        self.tk_button_md761j02.bind('<Button>',self.ctl.choose_data_1)
        self.tk_button_md762af1.bind('<Button>',self.ctl.choost_data_2)
        self.tk_button_md76csod.bind('<Button>',self.ctl.parse_instruction)
        self.tk_button_md76cuu3.bind('<Button>',self.ctl.parse_kernel)
        self.tk_button_md77ygzz.bind('<Button>',self.ctl.choose_output)
        pass
    def __style_config(self):
        pass
if __name__ == "__main__":
    win = WinGUI()
    win.mainloop()